﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using IDAL;
using DALFactory;
using System.Collections;
using Model;

//User业务逻辑层
//返回hash表, result结果,,message信息,
namespace BLL
{
    public class UserService
    {
        private static readonly IUser dal = DALFactory.DataAccess.createUser();

        //注册
        public Hashtable regist(string email, string password, string name, string sex)
        {
            //1格式检测
            //2调用DAL层 存入数据库
            User user = new User();
            //临时用
            //产生唯一ID
            int iResult;
            Random ro = new Random();
            int iUp = 1000000;
            iResult = ro.Next(iUp);
            user.Id = iResult;
            user.Email = email;
            user.Password = password;
            user.Name = name;


            /* if (sex != "")
             {
                 user.Sex = int.Parse(sex);
             }*/
            user.Sex = 1;
            dal.saveUser(user);
            Hashtable ht = new Hashtable();
            ht.Add("result", "1");
            ht.Add("message", "注册成功");
            return ht;
        }
        //登陆
        public Hashtable login(string email, string password)
        {
            Hashtable ht = new Hashtable();
            ht.Add("result", "0");
            ht.Add("message", "用户不存在");
            return ht;
        }
        //修改资料
        public Hashtable modify(string email, string password, string name, int sex)
        {
            return null;
        }
    }
}
